<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 300px;
            margin: 0 auto;
        }
        #boxs{
            width: 200px;
            height: 200px;
            background: #000;
            color: #fff;
            font-size: 12px;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div id="box">
        <p>属性名：<input type="text" id="inp1" value="background" ></p>
        <p>属性值：<input type="text" id="inp2" value="blue"></p>
        <input type="button" value="确定" id="btn1">
        <input type="button" value="重置" id="btn2">
        <div id="boxs">
            在上方输入框输入"属性名"及"属性值"，点击确定按钮查看效果
        </div>
    </div>
</body>
<script>
    var change = function(z1,x1,y1){
        z1.style[x1] = y1
    }
    window.onload = function(){
        var inp1 = document.getElementById('inp1')
        var inp2 = document.getElementById('inp2')
        var btn1 = document.getElementById('btn1')
        var btn2 = document.getElementById('btn2')
        var boxs = document.getElementById('boxs')
        btn1.onclick = function(){
            var x = inp1.value
            var y = inp2.value
            change(boxs,x,y)
        }
        btn2.onclick = function(){
            boxs.removeAttribute('style')
        }
    }
    
</script>
</html>